package cn.edu.gzccc.chapter422.utils;

import cn.edu.gzccc.chapter422.vo.ResultVO;

/**
 * 统一API接口响应结果生成工具
 */
public class ResultVOUtils {

    public static <T>ResultVO<T> success(T data){
        ResultVO<T> vo = new ResultVO<>();
        vo.setCode(200);
        vo.setMsg("success");
        vo.setData(data);
        return vo;
    }
    public static <T>ResultVO<T> success(){
        ResultVO<T> vo = new ResultVO<>();
        vo.setCode(200);
        vo.setMsg("success");
        vo.setData(null);
        return vo;
    }

    public static <T>ResultVO<T> fail(){
        ResultVO<T>  vo = new ResultVO<>();
        vo.setCode(500);
        vo.setMsg("未知错误，请联系系统管理员");
        vo.setData(null);
        return vo;
    }

    public static <T>ResultVO<T> fail(Integer code, String msg, T data){
        ResultVO<T>  vo = new ResultVO<>();
        vo.setCode(code);
        vo.setMsg(msg);
        vo.setData(data);
        return vo;
    }


}
